/*
 * Copyright (c) 2014. Lorem ipsum dolor sit amet, consectetur adipiscing elit.
 * http://www.apache.org/licenses/LICENSE-2.0
 */

package com.dc.gameserver.extComponents.springDataRedisCache;

import com.dc.gameserver.extComponents.springDataRedisCache.Operations.stringObjectOperations;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.io.Serializable;

/**
 * @author 石头哥哥
 *         Date: 13-11-25</br>
 *         Time: 下午6:24</br>
 *         Package: com.dc.gameserver.extComponents.redisCache</br>
 *         注解：
 */
@Service
public class RedisServiceStringObject implements stringObjectOperations {

    @Resource
    private RedisTemplate<String, Serializable> redisTemplate;
    /**
     * @param key
     * @param serializable 其中 list中的数据应该实现序列化接口
     */
    @Override
    public void set(String key, Serializable serializable) {
        redisTemplate.opsForValue().set(key,serializable);
    }

    /**
     * @return
     */
    @Override
    public Serializable get(String key) {
        return redisTemplate.opsForValue().get(key);
    }

    /**
     * 删除 缓存 key对应的value
     *
     * @param key
     */
    @Override
    public void del(String key) {
        redisTemplate.delete(key);
    }
}
